/*#include "Platform.h"
#include "avsmallft.h"*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace Droplet
{
    public struct drft_lookup{
        public static int n;
        public static float[] trigcache = new float[1];
        public static int[] splitcache = new int[1];
    }
    
    public class Warp
    {
        public static Smallft ft = new Smallft();
        public static drft_lookup [] spx_fft_init( int size)
        {
            drft_lookup[] table;
          //  table = new drft_lookup[Marshal.SizeOf(100)];//(drft_lookup[])calloc(sizeof(drft_lookup),1);
            table = new drft_lookup[1];
            Smallft.spx_drft_init(table,size);
            return table;
        }

        public static void spx_fft_destroy(drft_lookup [] table)
        {
            Smallft.spx_drft_clear(table);
           // table.Close();
            table = null;
        }

        public static void spx_fft(drft_lookup [] table,float[] input,float[] output)
        {
            if (input == output)
            {
                int i;
                float scale = 1.0f / drft_lookup.n;
             //   fprintf(stderr,"warning: %s\n","FFT should not be done in-place");
                for (i = 0; i < drft_lookup.n; i++)
                    output[i] = scale*input[i];
            }
            else
            {
                int i;
                float scale = 1.0f / drft_lookup.n;
                for (i = 0; i < drft_lookup.n; i++)
                    output[i] = scale*input[i];
            }
            Smallft.spx_drft_forward(table, output);
        }

        public static void spx_ifft(drft_lookup [] table,float[] input,float[] output)
        {
            if (input == output)
            {
              //  fprintf(stderr,"warning: %s\n","FFT should not be done in-place");
            }
            else
            {
                int i;
                for (i = 0; i < drft_lookup.n; i++)
                    output[i] = input[i];
            }
            Smallft.spx_drft_backward(table, output);
        }
    }
}
